import { Component } from 'react'
import {View, Text } from '@tarojs/components'
import './index.scss'
import Taro from '@tarojs/taro'

export default class LgButton extends Component {
  state = {}

  componentDidMount () {}

  componentDidShow () {}

  componentDidHide () {}

  componentDidCatchError () {}

  render () {
    var props = this.props, className = "lg_btn oneline ", style = props.style || {}; 
    var type = props.type || "A", hollow, radius;
    if (type == "B") radius = true;
    if (type == "C") hollow = true;
    if (type == "D") {hollow = true, radius = true}
    if (hollow) {
      className += "lg_btn_type1 ";
      if (props.color) className += "lg_btn_color1_" + props.color + " ";
      if (props.height) {
        style.height = Taro.pxTransform(props.height);
        style.lineHeight = Taro.pxTransform(props.height);
      }
    } else {
      className += "lg_btn_type ";
      if (props.color) className += "lg_btn_color_" + props.color + " ";
      if (props.height) {
        style.height = Taro.pxTransform(props.height);
        style.lineHeight = Taro.pxTransform(props.height - 2);
      }
    }
    if (props.width) style.width = Taro.pxTransform(props.width);
    if (radius) {
      className += "lg_btn_radius ";
      if (props.height) {
        style.borderRadius = Taro.pxTransform(props.height / 2);
      }
    }
    if (props.className) className += props.className;
    return (
        <View className={className} 
              style={style}
              onClick={() => { this.props.onClick && this.props.onClick(props.backData || "")}}>
            {props.children || ""}
        </View>
    )
  }
}